<template>
	<view class="container">
		<button type="primary" @click="scanCode">扫码</button>
		<view class="">
			条码类型：{{scanType}}
		</view>
		<view class="">
			内容：{{result}}
		</view>
		<!-- 底部tabbar -->
		<custom-tabbar></custom-tabbar>
	</view>
</template>

<script setup>
import { reactive, toRefs } from 'vue';
	const state = reactive({
		scanType:'',
		result:''
	})
	const {scanType,result} = toRefs(state)
	
	//扫码
	const scanCode = () => {
		// 允许从相机和相册扫码
		uni.scanCode({
			success: function (res) {
				// console.log('条码类型：' + res.scanType);
				state.scanType = res.scanType
				// console.log('条码内容：' + res.result);
				state.result = res.result
			}
		});
	}
</script>

<style lang="scss" scoped>
.container{
	box-sizing: border-box;
	width: 100vw;
	height: 100vh;
	padding-top: var(--status-bar-height);
	position: relative;
}
</style>
